package com.hitqz.robot.api.business.enums;

import com.hitqz.robot.api.common.dto.form.FormFieldConfigDto;

public enum TicketsFormFieldEnum {

    //在生成vo的时候options要通过查数据库去生成  [{"value":"point_1","label":"点位1"},{"value":"point_2","label":"点位2"}]

    TARGET_POS_CODE("tickets_params_agv","targetPosCode", "目标点位编码", "radio", null, null),

    SOURCE_POS_CODE("tickets_params_agv","sourcePosCode", "起始点位编码", "radio", null, null),

    PATROL_ITEM_IDS("tickets_params_patrol","patrolItemIds", "巡检项列表", "transfer", null, null),

    PATROL_END_POS_ID("tickets_params_patrol","patrolEndPosId", "结束后停留位置", "select", null, null),

    EQUIPMENT_LIST("tickets_params_custom","equipmentList", "设备列表", "select", null, null),


    ;

    private final String formName; // 表单名称
    private final String fieldName;      // 字段名称 (业务逻辑使用)
    private final String fieldLabel;     // 字段标签 (表单展示使用)
    private final String fieldType;      // 字段类型 (如 text, radio, checkbox)
    private final String defaultValue;   // 默认值
    private final String options;        // 选项 (JSON 字符串，针对 radio, select 等类型)
    private final Integer minValue;      // 最小值 (用于数值类型)
    private final Integer maxValue;      // 最大值 (用于数值类型)

    // 枚举构造函数
    TicketsFormFieldEnum(String formName,String fieldName, String fieldLabel, String fieldType, String defaultValue, String options) {
        this(formName,fieldName, fieldLabel, fieldType, defaultValue, options, null, null);
    }

    TicketsFormFieldEnum(String formName,String fieldName, String fieldLabel, String fieldType, String defaultValue, String options, Integer minValue, Integer maxValue) {
        this.formName = formName;
        this.fieldName = fieldName;
        this.fieldLabel = fieldLabel;
        this.fieldType = fieldType;
        this.defaultValue = defaultValue;
        this.options = options;
        this.minValue = minValue;
        this.maxValue = maxValue;
    }

    // 生成 FormFieldConfigDto 的方法
    public FormFieldConfigDto toConfigDto() {
        return new FormFieldConfigDto(
                this.fieldName,
                this.fieldLabel,
                this.fieldType,
                this.defaultValue,
                this.defaultValue,  // 初始化当前值为默认值
                true,               // 是否必填
                this.minValue,
                this.maxValue,
                null,       // 正则表达式
                this.options
        );
    }

    // Getter 方法
    public String getFieldName() {
        return fieldName;
    }

    public String getFieldLabel() {
        return fieldLabel;
    }

    public String getFieldType() {
        return fieldType;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public String getOptions() {
        return options;
    }

    public Integer getMinValue() {
        return minValue;
    }

    public Integer getMaxValue() {
        return maxValue;
    }

    public String getFormName() {
        return formName;
    }
}